<div class="AppRepository" [hidden]="!project.vcs_servers || project.vcs_servers.length === 0">

    <form class="ui form" (ngSubmit)="linkRepository()" [hidden]="application.vcs_server">
        <div class="fields">
            <div class="three wide field">
                <label>{{'repoman_name' | translate}}</label>
                <sm-select class="fluid search"
                    name="repomanname"
                    [disabled]="loadingRepos || application.from_repository"
                    [(model)]="selectedRepoManager"
                    [options]="{'fullTextSearch': true}"
                    (onChange)="updateListRepo(false)">
                    <option *ngFor="let r of project?.vcs_servers" value="{{r.name}}">{{r.name}}</option>
                </sm-select>
            </div>
            <div class="five wide field">
                <label>{{'repo_name' | translate}}</label>
                <sm-select
                    class="search item"
                    placeholder="{{'application_repo_choose' | translate}}"
                    [(model)]="selectedRepo"
                    [options]="{'fullTextSearch': true}"
                    (onSearchChange)="filterRepositories($event)"
                    [disabled]="loadingRepos || application.from_repository">
                    <option *ngFor="let r of reposFiltered"  value="{{r.fullname}}">{{r.fullname}}</option>
                </sm-select>
            </div>
            <div class="four wide field">
                <button name="resync" class="ui blue button" [class.loading]="loadingRepos" type="button"
                    (click)="updateListRepo(true)"
                >{{ 'btn_resync_repo' | translate }}</button>
            </div>
            <div class="four wide right aligned field">
                <button name="addrepobtn" class="ui green button" [class.loading]="loadingBtn" [disabled]="loadingBtn || application.from_repository" type="submit">{{ 'btn_link' | translate }}</button>
                <app-warning-modal [title]="_translate.instant('warning_modal_title')" [msg]="_translate.instant('warning_modal_body')" (event)="linkRepository(true)" #linkWarning></app-warning-modal>
            </div>
        </div>
    </form>
    <div [hidden]="!application.vcs_server">
        <form class="ui form" [hidden]="!application.vcs_server">
            <div class="fields">
                <div class="eight wide field">
                    <span>{{application.vcs_server}}</span>
                    <span> &#10145; </span>
                    <span>{{application.repository_fullname}}</span>
                </div>
                <div class="eight wide right aligned field">
                    <app-delete-button [loading]="loadingBtn" [disabled]="loadingBtn || application.from_repository" (event)="removeRepository()"></app-delete-button>
                    <app-warning-modal [title]="_translate.instant('warning_modal_title')" [msg]="_translate.instant('warning_modal_body')" (event)="removeRepository(true)" #removeWarning></app-warning-modal>
                </div>
            </div>
        </form>
        <div *ngIf="application.repository_fullname" class="strategy">
            <div class="ui orange icon message mt5" *ngIf="!application.vcs_strategy || !application.vcs_strategy.connection_type">
              <i class="warning sign icon"></i>
              <div class="content">
                <div class="header">
                  {{'application_repo_missing_conf' | translate}}
                </div>
                <p>{{'application_repo_missing_conf_details' | translate}}</p>
              </div>
            </div>
            <h4 class="pointing" (click)="displayVCSStrategy = !displayVCSStrategy">
                <i class="right caret icon" *ngIf="!displayVCSStrategy"></i>
                <i class="down caret icon" *ngIf="displayVCSStrategy"></i>
                {{ 'application_repo_strat_title' | translate }}
            </h4>
            <div class="detail" [class.active]="displayVCSStrategy">
                <app-vcs-strategy [hideButton]="application.from_repository" [project]="project" [(strategy)]="application.vcs_strategy" (strategyChange)="saveVCSConfiguration()" [appName]="application.name" [loading]="loadingBtn"></app-vcs-strategy>
            </div>
        </div>
    </div>
</div>
<div [hidden]="project.vcs_servers && project.vcs_servers.length > 0">
    <p>
        {{ 'application_repoman_cant' | translate }}<a [routerLink]="['/project', project.key]" [queryParams]="{tab: 'advanced'}">{{'application_repoman_cant_link' | translate}}</a>
    </p>
</div>
